/************************************************************************************
* FileSystemMediaLoader.h                                                           *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef MEDIALOADER_H
#define MEDIALOADER_H

#include <QObject>
#include <phonon/MediaObject>
#include <QList>
#include <QStringList>
#include <QUrl>
#include <QThread>

#include "MediaItem.h"



class FileSystemMediaLoader : public QThread
{
    Q_OBJECT

protected:
    void run();
    QList<QString> m_extFilter;
    QList<MediaItem*>* m_mediaList;
    QList<QUrl>* m_urls;
    virtual void populateFilesPaths(QString dirPath, QList<QString>& filesToLoad);
    virtual void addToMediaList(Phonon::MediaSource* source);

public:
    explicit FileSystemMediaLoader(QObject *parent = 0);
    virtual ~FileSystemMediaLoader();

signals:
    void loadingStarted(int itemToLoad);
    void loaded(MediaItem* item);
    void progress(int filesLoaded, QString fileName);
    void errorOccured(const QString errorString);
    void finishedLoading(QList<MediaItem*>* items);

public slots:
    virtual void clear();
    virtual bool load(QList<QUrl>* urlList);
};

#endif // MEDIALOADER_H
